<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>离线下载</title>
    <script src="./js/LiteJS/Lite.js" type="text/javascript"></script>
</head>

<body>
<div class="mui-content" id="content">
    <form class="mui-input-group">
        <div class="mui-input-row">
            <label>下载链接</label>
            <input type="text" class="mui-input-clear remote_url" placeholder="请输入下载链接">
        </div>
        <div class="mui-input-row">
            <label>自定文件名</label>
            <input type="text" class="mui-input-clear file_name" placeholder="请输入文件名">
        </div>
        <div class="mui-button-row">
            <button id="confirm" type="button" class="mui-btn mui-btn-primary" >确认</button>
            <button type="button" class="mui-btn mui-btn-danger" >取消</button>
        </div>
    </form>
</div>

<script src="./js/common.js" type="text/javascript"></script>

<script type="text/javascript">
    function _callback() {
        buildDelegate();
    }

    function buildDelegate(){
        document.querySelector("#confirm").addEventListener("click", function(){
            var remote_url = document.querySelector(".remote_url").value;
            var file_name = document.querySelector(".file_name").value;
            if(!remote_url){
                return mui.alert("下载地址不能为空");
            }
            $http({
                url: "./storage/delegate.yx",
                method: "post",
                data: {
                    createUser: "alex",
                    file_name: file_name,
                    remoteFilePath: remote_url
                },
                async: false,
                success: function (responseText) {
                    console.info(JSON.parse(responseText));
                },
                Error: function (err_msg) {
                    console.error(err_msg);
                }
            });
        })
    }
</script>

</body>

</html>